<!doctype html>
<html lang="zh-CN">

<head>
  <!-- 必须的 meta 标签 -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap 的 CSS 文件 -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"
    integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
  <style>

    .login_box {
      width: 500px;
      border: 1px solid #778899;
      transform: translateY(100%);
      padding-top: 20px;
    }
  </style>
  <title>后台管理系统登录界面</title>
</head>

<body>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
    integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
    crossorigin="anonymous"></script>


  <!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-LCPyFKQyML7mqtS+4XytolfqyqSlcbB3bvDuH9vX2sdQMxRonb/M3b9EmhCNNNrV" crossorigin="anonymous"></script> -->
    <div class="login_box container">
      <div style="text-align: center;margin-bottom: 10px;">校园后台管理系统</div>
      <form method="POST" action="/admin/login">
        <div class="form-group row">
          <label for="username" class="col-sm-2 col-form-label col-form-label-sm">用户名:</label>
          <div class="col-sm-10">
            <input type="text" class="form-control col-form-label-sm" id="username" name="username">
          </div>
        </div>
        <div class="form-group row">
          <label for="password" class="col-sm-2 col-form-label col-form-label-sm">密码:</label>
          <div class="col-sm-10">
            <input type="password" class="form-control col-form-label-sm" id="password" name="password">
          </div>
        </div>
        <div class="form-group row">
          <label for="inputPassword3" class="col-sm-2 col-form-label col-form-label-sm"></label>
          <div class="col-sm-10">
            <button type="submit" class="btn btn-primary btn-sm">登录</button>
            <button type="button" class="btn btn-primary btn-sm" onclick="add()">重置</button>
          </div>
        </div>
      </form>
  </div>


  <script>
    // 对表单进行验证
    $('form').on('submit', function () {
      if ($('#username').val().trim().length < 4) {
        alert('请正确输入用户名');
        return false;
      }

      if ($("#password").val().trim().length < 5) {
        alert('请正确输入密码');
        return false;
      }
    })

    // 阻止浏览器默认行为并让浏览器重新刷新页面完成数据重置
    function add() {
      $("form").submit(function (e) {
        e.preventDefault();
      });
      window.location.href = "/admin/login";
    }
  </script>

</body>

</html>